package com.tianhao.common.entity;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

/**
 * 存放响应体的基础信息
 * @author: tianhao.luo@hand-china.com 2021/3/25  9:24
 */
public class ResponsePayloadDTO extends ResponseEntity {
    /**
     * 请求响应状态
     */
    private String status;
    /**
     * 请求成功/失败消息
     */
    private String message;
    /**
     * 请求内容类型
     */
    private String mediaType;
    /**
     * 实际接口响应内容
     */
    private String payload;
    /**
     * api信息
     */
    private ApiInfo apiInfo;
    /**
     * token令牌
     */
    private String invokeKey;

    public ResponsePayloadDTO() {
        super(HttpStatus.OK);
    }

    public ResponsePayloadDTO(Integer status, String message, String payload, String mediaType, ApiInfo apiInfo) {
        super(HttpStatus.OK);
        this.status = status.toString();
        this.message = message;
        this.payload = payload;
        this.mediaType = mediaType;
        this.apiInfo = apiInfo;
    }

    public String getStatus() {
        return this.status;
    }

    public ResponsePayloadDTO setStatus(String status) {
        this.status = status;
        return this;
    }

    public String getMessage() {
        return this.message;
    }

    public ResponsePayloadDTO setMessage(String message) {
        this.message = message;
        return this;
    }

    public String getMediaType() {
        return this.mediaType;
    }

    public ResponsePayloadDTO setMediaType(String mediaType) {
        this.mediaType = mediaType;
        return this;
    }

    public String getPayload() {
        return this.payload;
    }

    public ResponsePayloadDTO setPayload(String payload) {
        this.payload = payload;
        return this;
    }

    public ApiInfo getApiInfo() {
        return this.apiInfo;
    }

    public ResponsePayloadDTO setApiInfo(ApiInfo apiInfo) {
        this.apiInfo = apiInfo;
        return this;
    }

    public String getInvokeKey() {
        return this.invokeKey;
    }

    public void setInvokeKey(String invokeKey) {
        this.invokeKey = invokeKey;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("ResponsePayloadDTO{");
        sb.append("status='").append(status).append('\'');
        sb.append(", message='").append(message).append('\'');
        sb.append(", mediaType='").append(mediaType).append('\'');
        sb.append(", payload='").append(payload).append('\'');
        sb.append(", apiInfo=").append(apiInfo);
        sb.append(", invokeKey='").append(invokeKey).append('\'');
        sb.append('}');
        return sb.toString();
    }
}